package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.Type;
import com.bwie.service.TypeService;
import com.bwie.mapper.TypeMapper;
import com.bwie.utils.R;
import com.bwie.vo.TypeVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
* @author 14867
* @description 针对表【type】的数据库操作Service实现
* @createDate 2024-08-15 09:12:46
*/
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type>
    implements TypeService{
    @Resource
    private TypeMapper typeMapper;
    @Override
    public R getTypePage(TypeVo typeVo) {
        Page<Type> typePage = new Page<>(typeVo.getPageNum(),typeVo.getPageSize());
        QueryWrapper<Type> wrapper = new QueryWrapper<>();
        if(Objects.nonNull(typeVo.getTitle())){
            wrapper.lambda().like(Type::getTitle,typeVo.getTitle());
        }
        if(Objects.nonNull(typeVo.getStatus())){
            wrapper.lambda().eq(Type::getStatus,typeVo.getStatus());
        }
        Page<Type> pages = typeMapper.selectPage(typePage, wrapper);
        return R.OK(pages);
    }
}




